define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'my.delegation/index',
        add_url: 'my.delegation/add',
        edit_url: 'my.delegation/edit',
        delete_url: 'my.delegation/delete',
        export_url: 'my.delegation/export',
        modify_url: 'my.delegation/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                [
                    {
                            text: '添加',
                            url: init.add_url,
                            method: 'open',
                            auth: 'add',
                            class: 'layui-btn layui-btn-normal layui-btn-sm',
                            icon: 'fa fa-plus ',
                           // extend: 'data-full="true"',
                        }
                    ],
                ],
                cols: [[
                    {field: 'id', title: 'id', search: false},
                    {field: 'nickname', title: '用户昵称', search: false},
                    {field: 'phone', title: '电话', search: false},
                    {field: 'building_number', title: '楼号', search: false},
                    {field: 'unitarea', title: '户型面积', search: false},
                    {field: 'service_goodsname', title: '品牌名称', search: false},
                    {field: '', title: '是否取消参团', templet:function(d) {
                        if (d.is_cancel == 0) {
                            return '<a class="layui-btn layui-btn-sm"  data-request="my.delegation/grant?id='+d.id+'" data-title="确定取消吗？" data-table="currentTableRenderId">取消</a>';
                        } else {
                            return '已取消';
                        }
                    }},
                    {field: 'create_time', title: '参加时间', search: false},
                    {width: 250, title: '操作', templet: ea.table.tool},

                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});